"""消息队列展示"""
# 在windows 上要实现用队列管理进程需要对Queue进行重新初始化
from multiprocessing import Queue, Process,Manager
from time import sleep
from random import randint

# 摇号逻辑
def handle(q):
    for i in range(6):
        x=randint(1,33)
        q.put(x)
    q.put(randint(1,16))
# 出号逻辑
def request(q):
    while not q.empty():
        print("摇啊摇....")
        sleep(2)
        try:
            print(q.get())
        except:
            break


def main():
    manager = Manager()
    q = manager.Queue()
    p1 = Process(target=handle, args=(q,))
    p2 = Process(target=request, args=(q,))
    p1.start()
    p2.start()
    p1.join()
    p2.join()


if __name__=="__main__":
    main()




